<template>
    <div>
 <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="150px">
  <el-row :gutter="15">
    <el-col :span="15">
      <el-form-item label="角色标题" prop="title">
        <el-input v-model="formData.title" placeholder="请输入角色标题" clearable :style="{width: '100%'}"></el-input>
      </el-form-item>
    </el-col>
    <el-col :span="15">
      <el-form-item label="员工状态" prop="status">
        <el-radio-group v-model="formData.status" size="medium">
          <el-radio v-for="(item, index) in StatusOptions" :key="index" :label="item.value"
            :disabled="item.disabled">{{item.label}}</el-radio>
        </el-radio-group>
      </el-form-item>
    </el-col>
  <el-col :span="15">
      <el-form-item label="角色权限" prop="rules">
        <el-input v-model="formData.rules" placeholder="请输入角色权限" clearable :style="{width: '100%'}"></el-input>
      </el-form-item>
    </el-col>
  </el-row>
  <el-form-item size="large">
    <el-button type="primary" @click="submitForm">提交</el-button>
    <el-button @click="resetForm">重置</el-button>
    
  </el-form-item>
</el-form>

    </div>
   
</template>
<script>

import { AddAuthGroup } from "../../api/system.js";

export default {
  components: {},
  props: [],
  data() {
    return {
      formData: {
     title:'',
     rules:'',
     status:''
      },
      rules: {
        title: [{
          required: true,
          message: '请输入角色标题',
          trigger: 'blur'
        }],
  
        status: [{
          required: true,
          message: '角色状态不能为空',
          trigger: 'change'
        }],
        rules: [{
          required: true,
          message: '权限不能为空',
          trigger: 'change'
        }],
      
      },
      StatusOptions: [{
        "label": "删除",
        "value": 0
      }, {
        "label": "存在",
        "value": 1
      }],
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
  
    submitForm() {
      AddAuthGroup(this.formData)
      .then((res) => {
        if(res.code>0)
        {
          alert("添加成功");
          this.$router.push("/roles");
        }
        else{
          alert("添加失败");
        }
      });
      this.editVisible = false;
    },
    resetForm() {
      this.$refs['elForm'].resetFields()
    },
  }
}
</script>